Skip to content

Dynamic priority fee#570

Merged
GabrielMartinezRodriguez merged 6 commits intomasterfrom
gabriel/dynamic-priority-fee
Apr 13, 2025
Merged

Dynamic priority fee#570
GabrielMartinezRodriguez merged 6 commits intomasterfrom
gabriel/dynamic-priority-fee

Conversation

@GabrielMartinezRodriguez
Copy link
Contributor

@GabrielMartinezRodriguez GabrielMartinezRodriguez commented Mar 27, 2025

Linked Issues

Description

This PR introduces a new dynamic priority fee mechanism by adding support for fee history retrieval and updating transaction configuration accordingly

  • Include all relevant context (but no need to repeat the issue's content).
  • Draw attention to new, noteworthy & unintuitive elements.
Toggle Checklist

Checklist

Basics

  • B1. I have applied the proper label & proper branch name (e.g. norswap/build-system-caching).
  • B2. This PR is not so big that it should be split & addresses only one concern.
  • B3. The PR targets the lowest branch it can (ideally master).

Reminder: PR review guidelines

Correctness

  • C1. Builds and passes tests.
  • C2. The code is properly parameterized & compatible with different environments (e.g. local,
    testnet, mainnet, standalone wallet, ...).
  • C3. I have manually tested my changes & connected features.

< INDICATE BROWSER, DEMO APP & OTHER ENV DETAILS USED FOR TESTING HERE >

< INDICATE TESTED SCENARIOS (USER INTERFACE INTERACTION, CODE FLOWS) HERE >

  • C4. I have performed a thorough self-review of my code after submitting the PR,
    and have updated the code & comments accordingly.

Architecture & Documentation

  • D1. I made it easy to reason locally about the code, by (1) using proper abstraction boundaries,
    (2) commenting these boundaries correctly, (3) adding inline comments for context when needed.
  • D2. All public-facing APIs & meaningful (non-local) internal APIs are properly documented in code
    comments.
  • D3. If appropriate, the general architecture of the code is documented in a code comment or
    in a Markdown document.
  • D4. An appropriate Changeset has been generated (and committed) for changes that touch npm published packages (currently packages/core and packages/react), see here for more info.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 27, 2025

Deploying happychain with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1356e03
Status:🚫  Deploy failed.

View logs

@GabrielMartinezRodriguez GabrielMartinezRodriguez mentioned this pull request Mar 27, 2025
11 tasks
@GabrielMartinezRodriguez GabrielMartinezRodriguez mentioned this pull request Mar 27, 2025
11 tasks
@GabrielMartinezRodriguez GabrielMartinezRodriguez marked this pull request as ready for review March 27, 2025 13:24
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new dynamic priority fee mechanism by adding support for fee history retrieval and updating transaction configuration accordingly.

  • Adds safeFeeHistory method to safely wrap fee history queries in the common viem client utility.
  • Updates TransactionManager configuration to use a new gas property with explicit EIP-1559 and fee parameters.
  • Modifies GasPriceOracle to use the calculated target priority fee when suggesting gas fees.

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

File Description
support/common/lib/utils/safeViemClients.ts Adds safeFeeHistory wrapper method with error handling
packages/txm/lib/TransactionManager.ts Introduces a new gas config block and updates fee parameters
packages/txm/lib/GasPriceOracle.ts Updates fee calculations and introduces asynchronous block handling
apps/randomness/src/index.ts Updates configuration to use the new gas configuration format
Files not reviewed (1)
  • contracts/src/happy-accounts/samples/executors/BatchCallExecutor.sol: Language not supported

@linear
Copy link

linear bot commented Mar 27, 2025

HAPPY-372 Estimate `maxPriorityFeePerGas`

Implement a mechanism to predict the recommended maxPriorityFeePerGas while ensuring a minimum value is stabilized to guarantee that the sequencer always accepts the new block that includes our transaction when recommitting.

Context: #416 (comment)

@GabrielMartinezRodriguez GabrielMartinezRodriguez changed the title feat(txm): dynamic priority fee Dynamic priority fee Mar 27, 2025
@GabrielMartinezRodriguez GabrielMartinezRodriguez added the reviewing-1 Ready for, or undergoing first-line review label Mar 27, 2025
@GabrielMartinezRodriguez GabrielMartinezRodriguez force-pushed the gabriel/dynamic-priority-fee branch from 22fd6dd to 6e7f328 Compare March 27, 2025 15:39
@@ -0,0 +1,8 @@
{
"HappyCounter": "0x8D45cAd49F37CC512DAFFE6700ddc98084867E68",
"MockGasBurner": "0xdA504Bb1b736b04A5Aec28fD5d693Ad7447Ad438",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dunno whats going on with the network unknown, likely a mismatch with chainId's. dont think the contracts are changed so can probably just remove the deployments completely

safeGetTransactionCount: (
...args: Parameters<ViemPublicClient["getTransactionCount"]>
) => ResultAsync<Awaited<ReturnType<ViemPublicClient["getTransactionCount"]>>, GetTransactionCountErrorType>
safeFeeHistory: (
Copy link
Contributor

@aodhgan aodhgan Apr 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: lets fully qualify this -> safeGetFeeHistory, so there isnt any confusion as to the underlying RPC method

@@ -37,7 +39,7 @@ export class GasPriceOracle {
this.onNewBlock(block)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think we need to await here, now that its async?

@GabrielMartinezRodriguez GabrielMartinezRodriguez force-pushed the gabriel/dynamic-priority-fee branch 3 times, most recently from b2d5509 to ed80362 Compare April 8, 2025 13:01
@GabrielMartinezRodriguez GabrielMartinezRodriguez force-pushed the gabriel/dynamic-priority-fee branch from ed80362 to a1fd330 Compare April 10, 2025 07:52
@GabrielMartinezRodriguez GabrielMartinezRodriguez force-pushed the gabriel/dynamic-priority-fee branch from a1fd330 to 150a533 Compare April 10, 2025 08:01
@GabrielMartinezRodriguez GabrielMartinezRodriguez force-pushed the gabriel/dynamic-priority-fee branch from 150a533 to bdd1d5c Compare April 10, 2025 08:37
@GabrielMartinezRodriguez GabrielMartinezRodriguez force-pushed the gabriel/dynamic-priority-fee branch from bdd1d5c to d5bfe00 Compare April 10, 2025 08:51
@GabrielMartinezRodriguez GabrielMartinezRodriguez force-pushed the gabriel/dynamic-priority-fee branch from d5bfe00 to 44f4247 Compare April 10, 2025 09:12
@GabrielMartinezRodriguez GabrielMartinezRodriguez force-pushed the gabriel/dynamic-priority-fee branch from 44f4247 to 1f2858b Compare April 10, 2025 09:56
Base automatically changed from gabriel/txm-rpc-liveness to master April 10, 2025 20:11
@GabrielMartinezRodriguez GabrielMartinezRodriguez force-pushed the gabriel/dynamic-priority-fee branch from 1f2858b to 1356e03 Compare April 13, 2025 21:30
@GabrielMartinezRodriguez GabrielMartinezRodriguez merged commit b0c88f3 into master Apr 13, 2025
2 of 4 checks passed
@GabrielMartinezRodriguez GabrielMartinezRodriguez deleted the gabriel/dynamic-priority-fee branch April 13, 2025 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-blocked Ready to merge, waiting for downstack

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants